package zhenbang
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.text.TextField;
	public class StatisticsPage extends Sprite
	{
		private static var _main:StatisticsPage = null;
		public static function get main():StatisticsPage
		{
			if(_main==null)
				_main = new StatisticsPage();
			return _main;
		}
		public function StatisticsPage()
		{
			_main = this;
			addChild(new Bitmap(test.main.bg.bitmapData));
			width = test.stageW;
			height = test.stageH;

			var b00:Bitmap = new Assets.b00_png;
			b00.x = test.main.bg.width/2 - b00.width/2;
			b00.y = test.main.bg.height - b00.height/2;
			addChild(b00);

			//photoBtn = new BtnBase(toPhoto,test.newBtn("拍照留念"));
			photoBtn = new BtnBase(toPhoto,new Assets.b11_png);
			//signBtn = new BtnBase(toSign,test.newBtn("签名统计"));
			//signBtn = new BtnBase(toSign,new Assets.b12_png);
			//sayBtn = new BtnBase(toSay,test.newBtn("我要留言"));
			sayBtn = new BtnBase(toSay,new Assets.b13_png);
			addChild(photoBtn);
			//addChild(signBtn);
			addChild(sayBtn);
			photoBtn.y = sayBtn.y = 950;
			//signBtn.y = photoBtn.y;
			photoBtn.x = 186;
			//signBtn.x = 868;
			sayBtn.x = 1478;

			//[Embed(source="btn/back.png")] var backpng:Class; addChild(new backpng);
			line1txt = ViewSet.makeTxtLine("签名嘉宾总人数：",40,0xa41c20);
			line2txt = ViewSet.makeTxtLine("签名嘉宾总人数：",40,0xa41c20);
			line3txt = ViewSet.makeTxtLine("签名嘉宾总人数：",40,0xa41c20);
			zhitxt = ViewSet.makeTxtLine("至",40,0xa41c20);
			ren1txt = ViewSet.makeTxtLine("0人",40,0xa41c20);
			ren2txt = ViewSet.makeTxtLine("0人",40,0xa41c20);
			ren3txt = ViewSet.makeTxtLine("0人",40,0xa41c20);
			var _x:int = 1920*.7;
			line1txt.x = _x - line1txt.width;
			line2txt.x = _x - line2txt.width;
			line3txt.x = _x - line3txt.width;
			ren1txt.x = ren2txt.x = ren3txt.x = _x;
			line1txt.y = ren1txt.y = 200;
			line2txt.y = ren2txt.y = 300;
			line3txt.y = ren3txt.y = 400;


			addChild(line1txt);
			addChild(line2txt);
			addChild(line3txt);
			addChild(zhitxt);
			addChild(ren1txt);
			addChild(ren2txt);
			addChild(ren3txt);


			date0 = new DateEditor(Datas.date2str(),showSelectedDay);
			date1 = new DateEditor(Datas.date2str(),showSelectedDays1);
			date2 = new DateEditor(Datas.date2str(),showSelectedDays2);
			date0.x = line2txt.x - date0.width;
			date2.x = line2txt.x - date2.width;
			zhitxt.x = date2.x - zhitxt.width;
			date1.x = zhitxt.x - date1.width;
			zhitxt.y = line3txt.y;

			var deltaY:int = line2txt.height/2-date0.height/2+5;
			date0.y = line2txt.y + deltaY;
			date1.y = date2.y = line3txt.y + deltaY;
			addChild(date0);
			addChild(date1);
			addChild(date2);



			var backBtn:BtnBase = new BtnBase(back,new Assets.back_png);
			addChild(backBtn);
		}
		private static var date0:DateEditor;
		private static var date1:DateEditor;
		private static var date2:DateEditor;

		private static var line1txt:TextField;
		private static var line2txt:TextField;
		private static var line3txt:TextField;
		private static var ren1txt:TextField;
		private static var ren2txt:TextField;
		private static var ren3txt:TextField;
		private static var zhitxt:TextField;
		private var photoBtn:BtnBase;
		//private var signBtn:BtnBase;
		private var sayBtn:BtnBase;

		private function toPhoto():void
		{
			logs.adds("拍照");
			CameraPage.show();
		}
		private function toSign():void
		{
			logs.adds("签名统计");
		}
		private function toSay():void
		{
			logs.adds("留言");
			SayPage.show();
		}

		private function showSelectedDay(value:Array=null):void
		{
			ren2txt.text = "" + Datas.sumOfDay(value)+ "人";
		}
		private function showSelectedDays1(value:Array=null):void
		{
			ren3txt.text = "" + Datas.sumFromTo(value,date2.value) + "人";
		}
		private function showSelectedDays2(value:Array=null):void
		{
			ren3txt.text = "" + Datas.sumFromTo(date1.value,value) + "人";
		}

		private static var indexTxt:TextField;
		public static function show():void
		{
			main.visible = true;
			test.main.addChild(main);
			indexTxt = Datas.setIndexTxt(indexTxt);
			main.addChild(indexTxt);
			ren1txt.text = "" + Datas.index + "人";
			main.showSelectedDay(date0.value);
			main.showSelectedDays1(date1.value);
			main.showSelectedDays2(date2.value);


		}
		public static function back():void
		{
			main.visible = false;
			FirstPage.show();
		}
	}
}
